<?php

namespace App\Http\Controllers\Api\V2;

use Illuminate\Http\Request;
use App\Http\Requests\ApiV2\IninventoryManagementRequest;
use App\Http\Requests\ApiV2\OutinventoryManagementRequest;
use App\Services\Warehouse\Interfaces\InventoryManagementServiceInterface;
use Illuminate\Support\Facades\DB;
use App\Services\Warehouse\Services\InventoryManagementService;

class InventoryManagementController extends BaseController
{
    /**
     * @var PartsCategory
     */
    protected $inventoryManagementService;

    public function __construct(InventoryManagementServiceInterface $inventoryManagementService)
    {
        $this->inventoryManagementService = $inventoryManagementService;
    }

    public function listparams()
    {
        $freight_space = DB::table('k_freight_space')
        ->select([
            'id','position'
        ])
        ->orderBy('warehouse','asc')
        ->get();
        $equipment = DB::table('k_equipment')
        ->select([
            'id','equipmentName'
        ])
        ->orderBy('created_at','asc')
        ->get();
        return $this->data(compact('freight_space', 'equipment'));
    }

    public function in_warehouse(IninventoryManagementRequest $request,$id){
        $this->inventoryManagementService->in_warehouse($request->filldata(),$id);
        return $this->success();
    }

    public function receive(OutinventoryManagementRequest $request,$id)
    {
        $this->inventoryManagementService->receive($request->filldata(),$id);
        return $this->success();
    }

    public function need_repair(Request $request,$id)
    {
        $this->inventoryManagementService->need_repair($request->all(),$id);
        return $this->success();
    }

    public function out_repair(Request $request,$id)
    {
        $this->inventoryManagementService->out_repair($request->all(),$id);
        return $this->success();
    }


    public function scrap(Request $request,$id)
    {
        $this->inventoryManagementService->scrap($request->all(),$id);
        return $this->success();
    }

    public function apply_first_audit_receive(Request $request,$id)
    {
        $this->inventoryManagementService->apply_first_audit_receive($request->all(),$id);
        return $this->success();
    }

    public function first_audit_receive(Request $request,$id)
    {
        $this->inventoryManagementService->first_audit_receive($request->all(),$id);
        return $this->success();
    }
}
